(function(){
	angular.module('app')
		.factory('LoginFactory',fn);
	function fn(urlCnst,mockHttp,userService){
	    var self = {};
	    self.login = function (body,cb) {
            if( !urlCnst['mockHttp'] ){
                urlCnst.post('auth/login',body,cb);
            }
            else {
                var name = body['username'];
                if ( name in mockHttp['users'] ) {
                    setUser(0, mockHttp['users'][name]);
                    console.log(mockHttp['users'][name]);
                    return cb(0,mockHttp['users'][name]);
                }
                else {
                    return cb(1);
                }
            }
        };
		return self;
	}
})();
